import {SONG_LIST} from '../api'
export default (state,action)=>{
  state= state || {data:{}};
  switch(action.type){
    case 'INIT':
      return {data:action.data};
    default:
      return state;
  }
}

export const getSongList = (id) => (dispatch) => {
  fetch(SONG_LIST+'/'+id).then(data=>data.json()).then(res=>{
    setTimeout(()=>{
      dispatch({type:'INIT',data:res.data})
    },2)
  })
}